const Model = require('../db/models/courseCollection');
//修改

class Server { //修改
  //修改
  async addData (data) {
    //检查cid是否存在 check cid is existed
    const cid = data.cid; //修改
    //修改
    const result = await CourseCollectionModel.findOne({where: { cid }});
    //判断 check
    if (result) { 
      //更新 update  //修改
      return await CourseCollectionModel.update(data, {where: { cid }})
    }else {
      //创建 create
      return await CourseCollectionModel.create(data);
    }
  }
}
//修改
module.exports = new Server();